home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 026-050 / scopedisk33 / rxenv / rxmake.rexx < prev    next >
OS/2 REXX Batch file  |  1995-03-18  |  5KB  |  251 lines

  1. /*    Simple MAKE routine written in ARexx    */
  2.  
  3. address COMMAND
  4. drop Src. Obj.
  5.  
  6. 'set dateformat=-0'
  7. 'list Source:*.c to ram:$$source'
  8. 'list Obj:*.o to ram:$$obj'
  9.  
  10. call open( 'source', 'ram:$$source', 'R' )
  11. call open( 'obj', 'ram:$$obj', 'R' )
  12. call open( 'comp', 'ram:$$comp', 'W' )
  13.  
  14. arg compile_all
  15.  
  16. call readln( 'source' )
  17.  
  18. call getdateparms
  19. parmresult = 1
  20.  
  21. do forever
  22.     if eof( 'source' ) then break
  23.     instring = readln( 'source' )
  24.     call getparm
  25.     if parmresult = 0 then iterate
  26.  
  27.     Src. = fname
  28.     Src.sd = date
  29.     Src.st = time
  30.  
  31.     if ( compile_all ~== 'ALL' ) 
  32.         then do
  33.             gomf = 0
  34.             call seek( 'obj', 0, 'B' )
  35.             do forever
  36.                 if eof( 'obj' ) then gomf = 1
  37.                 if gomf then break
  38.                 instring = readln( 'obj' )
  39.                 call getparm
  40.                 if ( compare( Src., fname ) = 0) then break
  41.             end
  42.  
  43.             if gomf
  44.                 then call makecomp
  45.                 else do
  46.                     Obj. = fname
  47.                      Obj.od = date
  48.                      Obj.ot = time
  49.  
  50.                     call chkday( compare( Src.sd, Obj.od ) )
  51.                 end
  52.             end
  53.         else call makecomp
  54. end
  55.  
  56. call close( 'source' )
  57. call close( 'obj' )
  58.  
  59. call writeln( 'comp', 'rxlink Main' )
  60. call close( 'comp' )
  61.  
  62. 'delete ram:$$source'
  63. 'delete ram:$$obj'
  64. 'delete ram:$$date'
  65.  
  66. echo ''
  67. echo 'Type...'
  68. echo ''
  69. echo '       execute ram:$$comp'
  70. echo ''
  71. echo '                ...to begin the compile and link process.'
  72.  
  73. exit
  74.  
  75. getparm:
  76.     temp = pos( '.', instring ) - 1
  77.     if temp = -1 
  78.         then parmresult = 0
  79.         else do
  80.             parmresult = 1
  81.             fname = left( instring, temp )
  82.             date = subword( instring, 4, 1 )
  83.             time = subword( instring, 5, 1 )
  84.         end
  85. return(1)
  86.  
  87. a2d:
  88. arg string
  89.     tens = (c2d( substr(string,1,1) ) - 48) * 10
  90.     digits = (c2d( substr(string,2,1) ) - 48)
  91.     d = tens + digits
  92. return( d )
  93.  
  94. d2a:
  95. arg d
  96.     tens = d % 10 + 48
  97.     digits = d // 10 + 48
  98.     string = d2c(tens) || d2c(digits)
  99. return(string)
  100.  
  101. chkday:
  102. arg diff
  103.     if diff = 0
  104.         then call chkhrs
  105.         else call comparedates( Src.sd, Obj.od )
  106. return(1)
  107.  
  108. chkhrs:
  109.     hours = a2d( substr(Src.st,1,2) ) - a2d( substr(Obj.ot,1,2) )
  110.     diffmin = a2d( substr(Src.st,4,2) ) - a2d( substr(Obj.ot,4,2) )
  111.     diffsec = a2d( substr(Src.st,7,2) ) - a2d( substr(Obj.ot,7,2) )
  112.  
  113.     select
  114.         when hours < 0 then echo Src. 'will NOT be compiled...'
  115.         when hours > 0 then call makecomp
  116.         otherwise do
  117.             if diffmin < 0 
  118.                 then echo Src. 'will NOT be compiled...'
  119.                 else if diffsec < 0 
  120.                         then echo Src. 'will NOT be compiled...'
  121.                         else call makecomp
  122.         end
  123.     end
  124. return(1)
  125.  
  126. getdateparms:
  127.     dayname.1 = 'Sunday'
  128.     dayname.2 = 'Monday'
  129.     dayname.3 = 'Tuesday'
  130.     dayname.4 = 'Wednesday'
  131.     dayname.5 = 'Thursday'
  132.     dayname.6 = 'Friday'
  133.     dayname.7 = 'Saturday'
  134.  
  135.     'date >ram:$$date'
  136.  
  137.     call open( 'datefile','ram:$$date','R' )
  138.     instring = readln( 'datefile' )
  139.     call close( 'datefile' )
  140.  
  141.     day = subword( instring, 1, 1 )
  142.     date = subword( instring, 2, 1 )
  143.     todaysnum = dayofweek( day )
  144.  
  145.     dayname.todaysnum.fullnum = date
  146.     todaysdate = a2d( date,1,2 )
  147.  
  148.     call setdaydate
  149. return(1)
  150.  
  151. setdaydate:
  152. arg weekday
  153.     x = todaysnum
  154.     do i = 1 to 6
  155.         if x = 1
  156.             then x = 7
  157.             else x = x - 1
  158.         y = todaysdate - i
  159.         dayname.x.fullnum = d2a(y) || right(date, 7)
  160.     end
  161. return(1)
  162.  
  163. dayofweek:
  164. arg weekday
  165.     select
  166.         when weekday = 'SUNDAY' then datenumber = 1
  167.         when weekday = 'MONDAY' then datenumber = 2
  168.         when weekday = 'TUESDAY' then datenumber = 3
  169.         when weekday = 'WEDNESDAY' then datenumber = 4
  170.         when weekday = 'THURSDAY' then datenumber = 5
  171.         when weekday = 'FRIDAY' then datenumber = 6
  172.         when weekday = 'SATURDAY' then datenumber = 7
  173.         when weekday = 'TODAY' then datenumber = 8
  174.         when weekday = 'YESTERDAY' then datenumber = 9
  175.         otherwise datenumber = 0
  176.     end
  177. return(datenumber)
  178.  
  179. monthofyear:
  180. arg num
  181.     select
  182.         when num = 'JAN' then monthnum = 1
  183.         when num = 'FEB' then monthnum = 2
  184.         when num = 'MAR' then monthnum = 3
  185.         when num = 'APR' then monthnum = 4
  186.         when num = 'MAY' then monthnum = 5
  187.         when num = 'JUN' then monthnum = 6
  188.         when num = 'JUL' then monthnum = 7
  189.         when num = 'AUG' then monthnum = 8
  190.         when num = 'SEP' then monthnum = 9
  191.         when num = 'OCT' then monthnum = 10
  192.         when num = 'NOV' then monthnum = 11
  193.         when num = 'DEC' then monthnum = 12
  194.         otherwise monthnum = 0
  195.     end
  196. return(monthnum)
  197.  
  198. comparedates:
  199. arg Srcdate, Objdate
  200.     snum = dayofweek(Srcdate) 
  201.     if snum = 0 
  202.         then sdate = Srcdate
  203.         else if snum >= 8
  204.             then do
  205.                 temp = todaysnum - (snum - 8)
  206.                 sdate = dayname.temp.fullnum
  207.                 end
  208.             else sdate = dayname.snum.fullnum
  209.  
  210.     onum = dayofweek(Objdate) 
  211.     if onum = 0 
  212.         then odate = Objdate
  213.         else if onum >= 8
  214.             then do
  215.                 temp = todaysnum - (onum - 8)
  216.                 odate = dayname.temp.fullnum
  217.                 end
  218.             else odate = dayname.onum.fullnum
  219.  
  220.     call chkyear( sdate, odate )
  221. return(diff)
  222.  
  223. chkyear:
  224. arg s, o
  225.     if compare( right(s,2), right(o,2) )
  226.     then do
  227.         temp1 = a2d(right(s,2)
  228.         temp2 = a2d(right(o,2)
  229.     end
  230.     else do
  231.         if compare( substr(s,4,3), substr(o,4,3) )
  232.         then do
  233.             temp1 = monthofyear( substr(s,4,3) )
  234.             temp2 = monthofyear( substr(o,4,3) )
  235.             end
  236.         else do
  237.             temp1 = a2d(left(s,2))
  238.             temp2 = a2d(left(o,2))
  239.             end
  240.     end
  241.  
  242.     if ( (temp1 - temp2) >= 1 )
  243.         then call makecomp
  244.         else echo Src. 'will NOT be compiled...'
  245. return(1)
  246.  
  247. makecomp:
  248.     echo Src. 'will be compiled...'
  249.     call writeln( 'comp', 'rxcomp ' || Src. )
  250. return(1)
  251.